package top.kmtec.common;

/**
 * @Author FengHuan Wang
 * @Date 2025/2/5 14:11
 * @Version 1.0
 */
public class ResultUtils {
    /**
     * 请求成功
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResponse sucess(T data){
        return new BaseResponse<>(0, data, "ok");
    }

    /**
     * 请求失败
     * @param data
     * @return
     * @param <T>
     */
    public static BaseResponse error(ErrorCode errorCode){
        return new BaseResponse<>(errorCode);
    }

    /**
     * 请求失败
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode, String desc){
        return new BaseResponse<>(errorCode.getCode(), desc);
    }

    /**
     * 请求失败
     * @param errorCode
     * @return
     */
    public static BaseResponse error(Integer code, String message, String desc){
        return new BaseResponse<>(code,message, desc);
    }
}
